


//
//  ResidenceSearchView.m
//  住房条件帅选器
//
//  Created by MB__Lee on 2018/5/18.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "ResidenceSearchView.h"

@interface ResidenceSearchView()<AreaTableviewDelegate,BaseTypeTableVeiwDelegate,MBBTNTableviewDelegate>


@property(nonatomic,strong)BaseHousePostModel *model;

@end


@implementation ResidenceSearchView

#pragma mark ----方法实现


-(instancetype)initWithFrame:(CGRect)frame btnMut:(NSArray *)btnMut{
    if (self = [super initWithFrame:frame btnMut:btnMut]) {
        self.postModel.category = @"1001";
        _model = self.postModel;
    }
    return  self;
}


#pragma mark --- 子视图的代理方法
//1/选择区域的返回数据

-(void)AreaTableview:(AreaTableview *)areTable sendDistriceInfo:(NSString *)disctricName regionName:(NSString *)regionName{
    
    _model.district = disctricName;
    _model.region = regionName;
    [self resetFrameAndRemoveView:areTable];
}

//- (void)AreaTableview:(AreaTableview *)areTable sendDistriceModel:(ArDistrictModel *)disctricName regionModel:(ArRegionModel *)regionName {
//    
//    
//    if (![regionName.name isEqualToString:@"不限"]) {
//        
//     _model.district = disctricName.code;
//        _model.region = @"";
//    }else{
//        NSLog(@"--buxian--");
//        _model.district = disctricName.code;
//        _model.region = regionName.code;
//    }
//    
//    [self resetFrameAndRemoveView:areTable];
//    
//}
//2、--- 面积和租金 ---使用 --根据模型里面的 属性值来判断
-(void)BaseTypeTableVeiw:(BaseTypeTableVeiw *)tableview sendModel:(BaseModel *)model{
    
    _model.rent_end = model.value_end;
    _model.rent_start = model.value_start;
    [self resetFrameAndRemoveView:tableview];
    
}

//3、--- 户型      ---使用
-(void)BaseTypeTableVeiw:(BaseTypeTableVeiw *)tableview sendMin:(NSString *)min max:(NSString *)max{
    
    _model.square_end = max;
    _model.square_start = min;
    [self resetFrameAndRemoveView:tableview];
    
}

//4、--更多
-(void)MBBTNTableview:(MBBTNTableview *)tableview sendIndexPathArray:(NSMutableArray<NSIndexPath *>*)indexPathMut{
    for (NSIndexPath *indexPath in indexPathMut) {
        
        if (indexPath.section == 0) {  //特色
            _model.characteristic = [self stringAtIndexPath:indexPath tableView:tableview];
        }else if (indexPath.section == 1){// 装修
            _model.decoration = [self stringAtIndexPath:indexPath tableView:tableview];
        }else if (indexPath.section == 2){ //朝向
            _model.orientation = [self stringAtIndexPath:indexPath tableView:tableview];
        }
        
    }
    [self resetFrameAndRemoveView:tableview];
    
}
-(NSString *)stringAtIndexPath:(NSIndexPath *)indexPath tableView:(MBBTNTableview *)tableview{
    NSArray *array = tableview.mut[indexPath.section];
    return  array[indexPath.row];
}




#pragma mark ---直接生成对应的searchview 写死
//-(instancetype)creatSearchView{
//    ResidenceSearchView *re  = [[[self class] alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, MBScale(49)) btnMut:@[@"住宅",@"租金",@"户型",@"更多"]];
//    
//    // 区域
//    AreaTableview *area =[[AreaTableview alloc] initWithFrame:CGRectMake(0, MBScale(50), re.bounds.size.width, ArCellHeight * 7)];
//    area.delegate = re;
//    
//    
//    //租金
//    BaseTypeTableVeiw *rent =[MutiBaseFactory creatTableviewWithBaseType:BaseTypeModel withFrame:CGRectMake(0, MBScale(50), re.bounds.size.width, MBScale(370))];
//    [rent setMinPlaceHolder:@"最低价格" max:@"最高价格"];
//    
//    GetRentSource *rentTool = [[GetRentSource alloc] init];
//    [rentTool priceTableview_getRentSourceWithCategory:@"1001" success:^(NSArray *arr) {
//        rent.sourceMut = [NSMutableArray arrayWithArray:arr];
//    } failure:^(NSError *err) {
//        
//    }];
//    rent.BaseDelegate = re;
//    
//  
//    // 户型
//    BaseTypeTableVeiw *roomtype = [MutiBaseFactory creatTableviewWithBaseType:BaseTypeBottomBTN withFrame:CGRectMake(0, MBScale(50), re.bounds.size.width, MBScale(370))];
//    [roomtype setMinPlaceHolder:@"最小面积" max:@"最大面积"];
//    roomtype.BaseDelegate = re;
//    
//    
//    
//    CGFloat height = SCREEN_HIGHT - MBScale(50) - MBScale(64);
//    MBBTNTableview *btnTable = [MBBTNTableviewFactory MBBTNTableviewFactoryCreatWithType:HouseTypeResidence withFrame:CGRectMake(0,MBScale(50), re.bounds.size.width, height)];
//    btnTable.BTNDelegate = re;
//    
//    
//    re.viewArray = @[area,rent,roomtype,btnTable];
//    
//    return  re;
//}

@end
